package com.example.factory;

import com.example.entity.Animal;

import java.util.Properties;

public class AnimalFactory {

    public Animal getAnimal() {
        Properties properties = new Properties();
        try {
            properties.load(AnimalFactory.class.getClassLoader().getResourceAsStream("animal.properties"));
            String animal = properties.getProperty("animal");
            return (Animal) Class.forName(animal).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
